export function inBrowser(): boolean {
	return typeof window != "undefined";
}

export const getRootDomain = hostname => {
	// localhost
	if (!hostname.includes('.')) return hostname;
	// ip
	if (/^(\d+\.){3}\d+$/.test(hostname)) return hostname;
	// 普通域名
	return '.' + hostname.split('.').slice(-2).join('.');
};
